package com.chenchen.tiguan.venue.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chenchen.tiguan.common.annotation.Log;
import com.chenchen.tiguan.common.core.controller.BaseController;
import com.chenchen.tiguan.common.core.domain.AjaxResult;
import com.chenchen.tiguan.common.enums.BusinessType;
import com.chenchen.tiguan.venue.domain.Venue;
import com.chenchen.tiguan.venue.service.IVenueService;
import com.chenchen.tiguan.common.utils.poi.ExcelUtil;
import com.chenchen.tiguan.common.core.page.TableDataInfo;

/**
 * 场馆基础信息Controller
 * 
 * @author chenchen
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/venue/venue")
public class VenueController extends BaseController
{
    @Autowired
    private IVenueService venueService;

    /**
     * 查询场馆基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:list')")
    @GetMapping("/list")
    public TableDataInfo list(Venue venue)
    {
        startPage();
        List<Venue> list = venueService.selectVenueList(venue);
        return getDataTable(list);
    }

    /**
     * 导出场馆基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:export')")
    @Log(title = "场馆基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Venue venue)
    {
        List<Venue> list = venueService.selectVenueList(venue);
        ExcelUtil<Venue> util = new ExcelUtil<Venue>(Venue.class);
        util.exportExcel(response, list, "场馆基础信息数据");
    }

    /**
     * 获取场馆基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:query')")
    @GetMapping(value = "/{venueId}")
    public AjaxResult getInfo(@PathVariable("venueId") Long venueId)
    {
        return success(venueService.selectVenueByVenueId(venueId));
    }

    /**
     * 新增场馆基础信息
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:add')")
    @Log(title = "场馆基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Venue venue)
    {
        return toAjax(venueService.insertVenue(venue));
    }

    /**
     * 修改场馆基础信息
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:edit')")
    @Log(title = "场馆基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Venue venue)
    {
        return toAjax(venueService.updateVenue(venue));
    }

    /**
     * 删除场馆基础信息
     */
    @PreAuthorize("@ss.hasPermi('venue:venue:remove')")
    @Log(title = "场馆基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{venueIds}")
    public AjaxResult remove(@PathVariable Long[] venueIds)
    {
        return toAjax(venueService.deleteVenueByVenueIds(venueIds));
    }
}
